package com.xpchenfrank.test.supplier;

import java.util.function.Consumer;
import java.util.function.Supplier;

/**
 * @author xpchen
 * @time 2018/5/21 10:55
 * @Description
 * @copyright Wuxi Yazuo ,Ltd.copyright 2015-2025
 */
public class SupplierConsumer<T> extends Thread {

    private Supplier<T> supplier;
    private Consumer<T> consumer;
    private String threadName;

    private boolean shouldRun = true;

    public SupplierConsumer(Supplier<T> supplier, Consumer<T> consumer, String threadName) {
        this.supplier = supplier;
        this.consumer = consumer;
        this.threadName = threadName;
    }

    @Override
    public void run() {
        while (shouldRun) {
            T item = supplier.get();
            consumer.accept(item);
        }
    }

}
